<template>
	<view >
		 <record-line :emptyShow="emptyShow" :record_line_list="time_line_list" ref="recordline" class="timeLine animated bounceInLeft slow"></record-line>
		 <xw-empty :isShow="isShow" text="暂无相关记录" textColor="#777777"></xw-empty>
		<!-- 内容区 -->
	</view>
</template>

<script>
	import recordLine from '../../../components/purchase-record-line/purchase-record-line.vue';
	export default {
		data() {
			return {
				time:0,
				//时间轴数据
				time_line_list:[],
				record_line_list:[],
				emptyShow: false,
				isShow: false,
				person: '',
				farmId: ''
			}
		},
		components:{
			//timeLine,
			recordLine
		},
		methods: {
			//获取用户角色
			getRole(){
				this.person = this.User.userRight.name
				console.log(this.person)
			},
			
			//获取消毒记录
			init(){
				console.log(this.farmId);
				console.log(this.User)
				uni.request({
					url:this.confige.webUrl+'/livestock/listDisinfection_History',
					method: 'GET',
					data:{
						farm_id: this.farmId
					},
					header:{
						"X-Token":this.User.token
					},
					success: (res) => {
						console.log(res)
						if(res.data.result == null) {
							this.isShow = true
						}else{
							this.time_line_list = res.data.result[0].list
							this.isShow = false
						}
					}
				})
				this.swiperHeight = uni.getSystemInfoSync().windowHeight;
			}
		},
		//导航栏按钮点击监听
		onNavigationBarButtonTap:function(value){
			uni.navigateTo({
				url: './disinfection_stock'
			})
		},
		onLoad(option) {
			this.getRole()
			if(this.person === 'government'){
				this.farmId = option.farmId
			}else{
				this.farmId = this.User.userInfo.farm_id
			}	
		},
		onReady() {
			this.init()
		}
	}
</script>

<style lang="less">
	@import '../../../common/animate.css';
	
	.horizonal-tab {
		height: 80rpx;
		width: 750rpx;
		position: sticky;
		top: 0;
		z-index: 1;
		background: white;
	}
	
	
	.scroll-tab {
		white-space: nowrap;
		/* 必要，导航栏才能横向*/
		border-bottom: 1rpx solid white;
		text-align: center;
	}
	
	.scroll-tab-item {
		display: inline-block;
		/* 必要，导航栏才能横向*/
		margin: 20rpx 30rpx 0 30rpx;
		font-size: 36rpx;
		color: black;
		font-weight: bold;
	}
	
	.active .scroll-tab-line {
		border-bottom: 5rpx solid #4AC997;
		border-top: 5rpx solid #4AC997;
		border-radius: 20rpx;
		width: 140rpx;
	}
	
	//时间轴
	.timeLine {
		// padding-bottom:400rpx;
	}
	
	.recordLine {
		padding-bottom:400rpx;
	}
	
	.line {
		width: 2rpx;
		height: 240rpx;
		border-left: #07D188 solid 2px;
		margin-left: 60rpx;
	}
</style>
